//
//  AppDelegate.m
//  HMPersonalDoctor
//
//  Created by GD on 16/9/7.
//  Copyright © 2016年 geduo. All rights reserved.
//

#import "AppDelegate.h"
#import "KYTabbarController.h"
#import <SVProgressHUD.h>
#import <TencentOpenAPI/TencentOAuth.h>
#import <TencentOpenAPI/QQApiInterface.h>
#import "HMSideslipViewController.h"
#import <SMS_SDK/SMSSDK.h>

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)network
{
    // 1.创建网络监测单例
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    /*
     status
     AFNetworkReachabilityStatusUnknown          = -1, 不知道监测的是什么
     AFNetworkReachabilityStatusNotReachable     = 0,  没有检测到网络
     AFNetworkReachabilityStatusReachableViaWWAN = 1,  蜂窝网
     AFNetworkReachabilityStatusReachableViaWiFi = 2,  WIFI
     */
    // 2.实现网络监测的回调
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        NSLog(@"网络状态  2 方为正常%zd",status);
        
//        if (status != 2) {
//            [SVProgressHUD showWithStatus:@"网络不正常,请稍后重试"];
//        }
        
        
    }];
    [UMSocialData setAppKey:@"57d2dc57e0f55ab70c001420"];

    // 3.开始监测
    [manager startMonitoring];
}
-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
    }
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [SMSSDK registerApp:@"16f7cd39591c5"
             withSecret:@"2b120295fdcbfcdb28843b53809fd082"];
    // 1.创建窗口
    _window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    _window.backgroundColor = [UIColor whiteColor];
    
    // 2.设置窗口的根vc
    _window.rootViewController = [[HMSideslipViewController alloc] init];
    
    // 3.设置窗口主窗口并可见
    [_window makeKeyAndVisible];
    
    [self network];
    
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{
    return [TencentOAuth HandleOpenURL:url];
}
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{
    return [TencentOAuth HandleOpenURL:url];
//    a
}

@end
